package com.kylin.module.admin.business;

import java.util.List;

import com.kylin.common.exception.BusinessException;
import com.kylin.hibernate.BaseHibernateDAO;
import com.kylin.module.community.orm.Post;

public class ManagePostBlogic {
	
	/**
	 * 根据帖子id 删除 帖子记录
	 * @param id 帖子id
	 * @throws BusinessException
	 */
	public void deletePostById(Long id) throws BusinessException {
		BaseHibernateDAO.deleteById(Post.class, id);
	}
	/**
	 * 根据帖子id 查询帖子对象
	 * @param id 帖子id
	 * @throws BusinessException
	 */
	public Post selectPostById(Long id) throws BusinessException {
		return (Post) BaseHibernateDAO.findById(Post.class, id);
	}

	/**
	 * 根据帖子id 修改帖子状态为发布状态
	 * @param id 帖子id
	 * @throws BusinessException
	 */
	public void allowPostById(Long id) throws BusinessException {
		Post post =	(Post) BaseHibernateDAO.findById(Post.class, id);
		post.setActive(Post.ALLOW);
		BaseHibernateDAO.update(post);
	}

}
